//
//  AskForLeaveViewController.m
//  AttendenceSys
//
//  Created by ld on 16/1/14.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "AskForLeaveViewController.h"

@interface AskForLeaveViewController ()

@end

@implementation AskForLeaveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initData];
    [self initView];
    
    // Do any additional setup after loading the view.
}

-(void)initData
{
    _askForLearr = [[NSMutableArray alloc] initWithObjects:@"申请课时假", @"申请外出假",@"销外出假",@"申请课时假记录",nil];
}

-(void)initView
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_tableView registerClass:[AskForLeaTableViewCell class] forCellReuseIdentifier:NSStringFromClass([AskForLeaTableViewCell class])];
    [self.view addSubview:_tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_askForLearr count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AskForLeaTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([AskForLeaTableViewCell class])];
    [cell setBackgroundColor:[UIColor clearColor]];
    cell.titleLabel.text = [_askForLearr objectAtIndex:indexPath.row];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60.0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (0 == indexPath.row) {
//        ApplyForClassLeaveViewController* appForClassViewCtrl = [[ApplyForClassLeaveViewController alloc] init];
//        appForClassViewCtrl.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:appForClassViewCtrl animated:YES];
        
        ApplyForClaLeaTeaListViewController* appForClassViewCtrl = [[ApplyForClaLeaTeaListViewController alloc] init];
        appForClassViewCtrl.strNavTitle = @"申请课时假老师";
        appForClassViewCtrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:appForClassViewCtrl animated:YES];
    }
    
    if (1 == indexPath.row) {
        ApplyForOutHolidayViewController* appForForOutHolidayViewCtrl = [[ApplyForOutHolidayViewController alloc] init];
        appForForOutHolidayViewCtrl.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:appForForOutHolidayViewCtrl animated:YES];
    }
    
    if (2 == indexPath.row) {
        CancleOutHolidayViewController* detailViewCtrl = [[CancleOutHolidayViewController alloc] init];
        detailViewCtrl.bApplyClass = NO;
        [self.navigationController pushViewController:detailViewCtrl animated:YES];
    }
    
    if (3 == indexPath.row) {
        CancleOutHolidayViewController* detailViewCtrl = [[CancleOutHolidayViewController alloc] init];
        detailViewCtrl.bApplyClass = YES;
        [self.navigationController pushViewController:detailViewCtrl animated:YES];
    }
    
}

@end
